/*
 * p3905.cpp
 *
 *  Created on: 2013-5-30
 *      Author: zy
 */

#include<cstdio>
#include<cstring>
const int maxn = 1010;
const int INF = 0x7fffffff;
int dp[maxn][maxn], a[maxn], sum[maxn], q[maxn], l, r, tem[maxn][maxn];
int N, M, L;
int max(int x, int y)
{
	return x > y ? x : y;
}
int main()
{
	while (~scanf("%d%d%d", &N, &M, &L))
	{
		memset(dp, 0, sizeof(dp));
		memset(tem, 0, sizeof(tem));
		sum[0] = 0;
		for (int i = 1; i <= N; i++)
		{
			scanf("%d", &a[i]);
			sum[i] = sum[i - 1] + a[i];
		}
		for (int i = L; i <= N; i++)
			dp[i][0] = sum[i];
		for (int j = 1; j <= M; j++)
		{
			l = r = 1;
			memset(q, 0, sizeof(q));
			dp[0][j] = -INF;
			for (int i = j + L; i <= N; i++)
			{
				dp[i][j] = dp[i - 1][j - 1];
				while (l <= r && dp[i - L][j] - sum[i - L] >= dp[q[r]][j]
						- sum[q[r]])
					r--;
				r++;
				q[r] = i - L;
				dp[i][j] = max(dp[i][j], dp[q[l]][j] + sum[i] - sum[q[l]]);
			}
		}
		printf("%d\n", dp[N][M]);
	}
	return 0;
}
